package cuiyt.datastructure.queue.priorityqueue;

import cuiyt.datastructure.heap.BinaryHeap;
import cuiyt.datastructure.heap.Heap;

import java.util.Comparator;

/**
 * @author cyt
 * @describe 优先队列
 * @create 2021-01-10 20:30
 */
public class PriorityQueue<E> {
    private Heap<E> heap;

    public PriorityQueue(Comparator comparator) {
        heap = new BinaryHeap<E>(comparator);
    }

    public PriorityQueue() {
        this(null);
    }

    public E front() {
        return heap.get();
    }

    public E dnQueue() {
        return heap.remove();
    }

    public void enQueue(E element) {
        heap.add(element);
    }

    public int size() {
        return heap.size();
    }

    public boolean isEmpty() {
        return heap.isEmpty();
    }
}
